package com.geely.club.util.common;

import android.content.Context;
import android.util.DisplayMetrics;

/**
 * Created by mengyangyang on 2015-10-15.
 */
public class SizeUtil {
    private static DisplayMetrics dm;

    public static void init(Context context) {
        dm = context.getResources().getDisplayMetrics();
    }

    public static float px2dp(int px) {
        return px / dm.density;
    }

    public static int dp2px(float dp) {
        return (int) (dp / dm.density + 0.5f);
    }

    public static int getScreenWidth() {
        return dm.widthPixels;
    }

    public static int getScreenHeight() {
        return dm.heightPixels;
    }
}
